home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 680 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  899 b 

  1. Path: news1.cris.com!viking!Crawford
  2. From: Crawford@viking.cris.com (CRAWFORD)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: itoa on Unix
  5. Date: 8 Jan 1996 10:15:39 -0500
  6. Organization: Concentric Internet Services
  7. Message-ID: <Crawford.821113489@viking>
  8. References: <4cra6m$pop@baloo.pipex-sa.net>
  9. Reply-To: crawford@iac.net
  10. NNTP-Posting-Host: viking.cris.com
  11.  
  12. nic@pipex-sa.net (Nic Tjirkalli) writes:
  13. >I would greatly appreciate it if somebody could inform me of a simple
  14. >way to convert an integer to a string using gcc on unix.
  15.  
  16.  
  17. char    *itoa (int number)
  18. {
  19.     static char string[200 + 1];
  20.  
  21. sprintf (string, "%200d", number);
  22.  
  23. return string;
  24. }
  25.  
  26. char    *itoa_r (int number, char *string)
  27. {
  28. sprintf (string, %d, number);
  29.  
  30. return string;
  31. }
  32.  
  33.     With appropriate headers, naturally.
  34.  
  35. -- 
  36. Creature of the wheel, master of the internal combustion engine.
  37.  
  38. Robert Crawford                crawford@iac.net
  39. http://www.iac.net/~crawford
  40.